﻿<UserControl x:Class="WinAutomator.DiagramEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignWidth="300" Background="White"
             DataContext="{Binding DiagramEditorViewModel, Source={StaticResource Locator}}">

    <Canvas>
        <ComboBox ItemsSource="{Binding Items}" Margin="100,10,10,264"
                  SelectedValue="{Binding RootPlugin}" Height="30" Width="200" />



        <ItemsControl ItemsSource="{Binding Items}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentPresenter Content="{Binding UserControl}" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>

            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemContainerStyle>
                <Style TargetType="ContentPresenter">
                    <Setter Property="Canvas.Left" Value="{Binding Path=ViewModel.Left, Mode=TwoWay}" />
                    <Setter Property="Canvas.Top" Value="{Binding Path=ViewModel.Top, Mode=TwoWay}" />
                </Style>
            </ItemsControl.ItemContainerStyle>
        </ItemsControl>

        <ItemsControl ItemsSource="{Binding ItemsConnections}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Line X1="{Binding Connector1.AnchorPoint.X}" X2="{Binding Connector2.AnchorPoint.X}" Y1="{Binding Connector1.AnchorPoint.Y}" Y2="{Binding Connector2.AnchorPoint.Y}" Stroke="Black" />

                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
        
    </Canvas>

</UserControl>
